const { Service } = require('egg');
const BusinessError = require('../utils/businessError')

class UserService extends Service {
  async login ({ username, password }) {
    let account = await this.app.mysql.get('base_account', { username })
    if (account == null) {
      throw new BusinessError(403, '账号不存在')
    }
    if (account.password != password) {
      throw new BusinessError(403, '密码错误')
    }
    return account
  }
}

module.exports = UserService